<?php
/**
 * IG_Import_Txt
 *
 * @author maomao.thx@gmail.com
 * @copyright Copyright (c) 2009 Green Shore (http://www.oaiwgame.com)
 * @version $Id: Txt.php 644 2011-06-20 07:18:56Z lirong $
 */
Class IG_Import_Txt implements IG_Import_Interface
{

    private $_ra = array();

    private $_data;

    /**
     * 返回二维数组
     * @param array $arr
     * @return array
     */
    public function toArray($obj)
    {
        foreach ($obj->_data as $key=>$value) {
            $this->_ra[$key] = explode("\t",$value);
        }
        return $this->_ra;
    }

    /**
     * 读取Txt
     * @param string $filename
     */
    public function read($filename)
    {
        $fp = fopen($filename, "r");
        while (!feof($fp)) {
            $content = fgets($fp, filesize($filename));
            $this->_data[] = $content;
        }
    }
}